package edu.nf.vac.admin.controller;

import edu.nf.vac.admin.vo.ResultVO;
import edu.nf.vac.reservation.dto.ReservationDTO;
import edu.nf.vac.reservation.dto.ReservationPageDTO;
import edu.nf.vac.reservation.inf.ReservationService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author : QYM
 * @create 2022/4/6
 */
@RestController
public class ReservationController extends BaseController{
    @DubboReference(interfaceClass = ReservationService.class,version = "1.0.0")
    private ReservationService reservationService;

    /**
     * 列表所有的预约
     * @param dto
     * @param page
     * @param limit
     * @return
     */
    @GetMapping("/reservation/list")
    public ResultVO<List<ReservationDTO>> listReservation(ReservationDTO dto, int page, int limit){
        ReservationPageDTO pageDTO = reservationService.listReservation(dto, page, limit);
        return pageResult(pageDTO.getTotol(),pageDTO.getList());
    }

    /**
     * 查看某条预约详情
     * @param id
     * @return
     */
    @GetMapping("/reservation/{id}")
    public ResultVO<ReservationDTO> queryById(@PathVariable("id") int id){
        ReservationDTO dto = reservationService.queryById(id);
        return success(dto);
    }
}
